<?php
class Control_Recharge_redo {

	function redo() {
		$action = $this->getValue("action");
		if($action == 0) {
			$startDate 	= 	date('Y-m-d', time());
			$endDate 	= 	date('Y-m-d', time() + 86400);
			MooView::set('startDate', $startDate);
			MooView::set('endDate', $endDate);
			MooView::render('orderRedo');
		} else if ($action == 1) {
			
			$postData = array();
			
			$nowGame = $postData['game'] 		= $this->getValue("game");
			
			$game = $postData['game'] = MooObj::get('Game')->transportGame($postData['game']);
			
			$nowChannel = $postData['channel'] 	= $this->getValue("channel");
			$channel_lang = MooConfig::get("callbackchannel_lang.{$game}");
			
			if($channel_lang['zh_en'][$postData['channel']]) {
				$postData['channel'] = $channel_lang['zh_en'][$postData['channel']];
			}
			
			$postData['starttime'] 	= $this->getValue("startTime") ." 00:00:00";
			$postData['endtime'] 	= $this->getValue("endTime") ." 00:00:00";;
			$postData['type'] 		= $this->getValue("type");
			
			
			$startDate 	= 	$this->getValue("startTime");
			$endDate 	= 	$this->getValue("endTime");
			MooView::set('startDate', $startDate);
			MooView::set('endDate', $endDate);
			
			MooObj::get('Control_Data')->setPlatformData($postData['game'], "callback");
			
			MooView::set('nowGame', $nowGame);
			MooView::set('channel', $nowChannel);
			
			$redoUrl = MooConfig::get('redo.url');
			
// 			$redoUrl = "http://192.168.199.136/recharge/www/redo.php";
			$res = MooUtil::curl_send($redoUrl, $postData);
			
			if($res) {
				$data = MooJson::decode($res, true);
				if($data) {
					MooView::set('data', $data);
				}
			}
			
			MooView::render('orderRedo');
		}
	}
	
	/**
	 * 获取request的值
	 * @param unknown $key
	 * @return unknown|boolean
	 */
	private function getValue($key) {
		if($_REQUEST[$key]) {
			return $_REQUEST[$key];
		} else {
			return false;
		}
	}
	
}